package com.briup.ch07.object;

public class Test {
    public static void main(String[] args) {
        Student s1=new Student("张三",20,2000.0,false);
        System.out.println(s1);
        Student s2=new Student("张三",40,2000.0,true);
        System.out.println(s1==s2);//比较地址值
        System.out.println(s1.equals(s2));//equals值比较
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
        Student s3=s1;
        System.out.println(s3==s1);
        System.out.println(s3.equals(s1));
        System.out.println(s3.hashCode()==s1.hashCode());
        System.out.println(s1.getClass());
        System.out.println(s1.getClass().getName());
        System.out.println(s1.getClass().getPackage()
        +s1.getClass().getSimpleName());
        System.out.println(s3 instanceof Student);
        System.out.println(s3.getClass()==s1.getClass());
        String str1="abc";
        //str1="hello";//新开辟空间，之前abc空间就会等着回收
        String str2=new String("abc");
        String str3="abc";
        String str4=new String("abc");
        System.out.println(str1==str2);
        System.out.println(str1==str3);//标量是从常量池中找
        System.out.println(str2==str4);//new直接开辟新空间
    }
}
